import React, { PureComponent } from 'react'

function withAuth(Wrapper) {
  const NewCpn = props => {
    const {isLogin} = props
    if(isLogin) {
      return <Wrapper {...props}/>
    } else {
      return <h2>LoginPage</h2>
    }
  }

  NewCpn.displayName = 'Auth'

  return NewCpn
}

class CartPage extends PureComponent {
  render() {
    return (
      <h2>CartPage</h2>
    )
  }
}

const AuthCartPage = withAuth(CartPage)

export default class App extends PureComponent {
  render() {
    return (
      <div>
        <AuthCartPage isLogin={true}/>
      </div>
    )
  }
}